package lntu.r211.nw;

public class FounctionDemo02 {
    public static void main(String[] args) {
        Student stu = new Student();
        int[] arr = {1,2,3,4,10,5,6,4};
        stu.add(arr);
        System.out.println("总成绩是:"+stu.add(arr));
        stu.play(new Ball("篮球",20));
    }

}

class Student{
    String name;

    public int add(int[] arr){
        int sum=0;
        for (int x=0;x<arr.length;x++){
            sum+=arr[x];
        }
        return sum;
    }
    public void play(Ball b){
        System.out.println(this.name+"在玩"+b.brandname+"价值"+b.price);
    }
    public void feed(FunctionDemo03 a){
        System.out.println(this.name+"在喂食"+a.getName());
    }
}
class Ball{
    String brandname;
    double price;

    public Ball(String brandname, double price) {
        this.brandname = brandname;
        this.price = price;
    }

    public String getBrandname() {
        return brandname;
    }

    public void setBrandname(String brandname) {
        this.brandname = brandname;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
}